package org.example.contract.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.example.contract.domain.ContractCheck;
import org.example.contract.service.IContractCheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 合同审核Controller
 *
 * @author 小孟微信：xiaomengcode
 * @date 2024-05-03
 */
@Controller
@RequestMapping("/contract/contractCheck")
public class ContractCheckController extends BaseController
{
    private String prefix = "contract/contractCheck";

    @Autowired
    private IContractCheckService contractCheckService;

    @RequiresPermissions("contract:contractCheck:view")
    @GetMapping()
    public String contractCheck(String contractId,ModelMap mmp)
    {
        mmp.put("contractId",contractId);
        return prefix + "/contractCheck";
    }

    /**
     * 查询合同审核列表
     */
    @RequiresPermissions("contract:contractCheck:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ContractCheck contractCheck)
    {
        startPage();
        List<ContractCheck> list = contractCheckService.selectContractCheckList(contractCheck);
        return getDataTable(list);
    }

    /**
     * 导出合同审核列表
     */
    @RequiresPermissions("contract:contractCheck:export")
    @Log(title = "合同审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ContractCheck contractCheck)
    {
        List<ContractCheck> list = contractCheckService.selectContractCheckList(contractCheck);
        ExcelUtil<ContractCheck> util = new ExcelUtil<ContractCheck>(ContractCheck.class);
        return util.exportExcel(list, "合同审核数据");
    }

    /**
     * 新增合同审核
     */
    @GetMapping("/add")
    public String add(String contractId,ModelMap mmp)
    {
        mmp.put("contractId",contractId);
        return prefix + "/add";
    }

    /**
     * 新增保存合同审核
     */
    @RequiresPermissions("contract:contractCheck:add")
    @Log(title = "合同审核", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ContractCheck contractCheck)
    {
        return toAjax(contractCheckService.insertContractCheck(contractCheck));
    }
}
